﻿using Adapters.Adapters.Interfaces;
using Adapters.Data;
using Adapters.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Adapters.Adapters.Adapters
{
    public class ToDoDataAdapter : IToDoAdapter
    {
        public List<ToDo> GetAllTasks()
        {
            List<ToDo> model;
            using (ApplicationDbContext db = new ApplicationDbContext())
            {
                model = db.ToDos.ToList();
            }
            return model;
        }

        public int AddTask(ToDo model)
        {
            int result;
            using (ApplicationDbContext db = new ApplicationDbContext())
            {
                db.ToDos.Add(model);
                result = db.SaveChanges();
            }
            return result;
        }
    }
}